var XQueue  = function() {
    this._queue = {};
};

module.exports = XQueue;

XQueue.prototype.__defineGetter__("queue", function() { return this._queue; });

XQueue.prototype.forEach = function(cb) {
    for(var key in this._queue) {
        if(cb.call(this, key, this._queue[key], this._queue) === false)
            break;
    }
}

XQueue.prototype.push = function(uid, message) {
    this._queue[uid] = message;
}

XQueue.prototype.pop = function(uid, bErase) {
    var ret = this._queue[uid];
    if(bErase && bErase === true) {
        delete this._queue[uid];
    }
    return ret;
}

XQueue.prototype.erase = function(uid) {
    delete  this._queue[uid];
}

XQueue.prototype.clear = function() {
    this._queue = {};
}